package com.easylinkin.linkappapi.jglplant.entity;

import com.easylinkin.linkappapi.common.utils.DateUtil;
import lombok.Data;
import org.apache.commons.lang3.ObjectUtils;

import java.util.List;

@Data
public class JglExpertVo extends JglExpert {
    /**
     * 创建时间
     */
    private String createTimeStr;
    /**
     * 性别
     */
    private String genderStr;
    /**
     * 研究领域1
     */
    private String study1;
    /**
     * 研究领域2
     */
    private String study2;
    /**
     * 研究领域3
     */
    private String study3;


    public JglExpertVo(JglExpert jglExpert) {
        this.setName(jglExpert.getName());
        this.setGenderStr(jglExpert.getGender() == 0 ? "女" : "男");
        this.setCompany(jglExpert.getCompany());
        this.setJob(jglExpert.getJob());
        this.setStudyPlant(jglExpert.getStudyPlant());
        this.setRemark(jglExpert.getRemark());
        this.setCreateTimeStr(DateUtil.getYYYYMMDDHHMMSSDate(jglExpert.getCreateTime()));
        List<JglExpertResearchArea> jglExpertResearchAreaList = jglExpert.getJglExpertResearchAreaList();
        if (ObjectUtils.isNotEmpty(jglExpertResearchAreaList)) {
            for (int i = 0, jglExpertResearchAreaListSize = jglExpertResearchAreaList.size(); i < jglExpertResearchAreaListSize; i++) {
                JglExpertResearchArea jglExpertResearchArea = jglExpertResearchAreaList.get(i);
                StringBuilder sb = new StringBuilder();
                sb.append(jglExpertResearchArea.getType1())
                        .append(jglExpertResearchArea.getType2())
                        .append(jglExpertResearchArea.getType3())
                        .append(jglExpertResearchArea.getType4());
                if (i == 0) {
                    this.setStudy1(sb.toString());
                }
                if (i == 1) {
                    this.setStudy2(sb.toString());
                }
                if (i == 2) {
                    this.setStudy3(sb.toString());
                }

            }
        }
    }
}
